home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk121 / post1.1 / init.ps < prev    next >
Text File  |  1995-03-19  |  4KB  |  141 lines

  1. %! Post V1.1 initialisation file
  2. % (C) Adrian Aylward 1989, 1990
  3. %
  4. % You may freely copy, use, and modify this file
  5. %
  6. % This file should be run before most programs
  7.  
  8. % Ignore CTRL/D
  9.  
  10. <04> cvn {} def
  11.  
  12. % A dummy status dictionary
  13.  
  14. /statusdict 10 dict dup begin
  15. /waittimeout 0 def
  16. /checkpassword { 0 eq } bind def
  17. end def
  18.  
  19. % A dummy server dictionary
  20.  
  21. /serverdict 5 dict dup begin
  22. /exitserver { pop } bind def
  23. end def
  24.  
  25. % A scratch string
  26.  
  27. /=string 256 string def
  28.  
  29. % Run a program with save and restore
  30.  
  31. /runsave
  32. { /saveobject save def
  33.   run
  34.   saveobject restore
  35. } bind def
  36.  
  37. % Run a program displaying its name
  38.  
  39. /runprog
  40. { dup print (\n) print
  41.   runsave
  42. } bind def
  43.  
  44. % New cache parameters ops
  45.  
  46. /setcacheparams
  47. { counttomark 1 ge { dup setcachelimit } if
  48.   cleartomark
  49. } bind def
  50.  
  51. /currentcacheparams
  52. { mark cachestatus 6 { exch pop} repeat dup
  53. } bind def
  54.  
  55. % Select a font.  (Allow for redefinition of findfont after binding)
  56.  
  57. /selectfont
  58. { exch /findfont load exec exch
  59.   dup type /arraytype eq
  60.   { makefont }
  61.   { scalefont }
  62.   ifelse
  63.   setfont
  64. } bind def
  65.  
  66. % Load a font file.  Build the file name string from the font name, prefix
  67. % and suffix strings.  We pop the dictionary stack first, so that the
  68. % contents of any additional entries on it can't interfere with the font
  69. % definition - e.g. if it uses the bind operator.  Then we try to open the
  70. % file.  If it opens OK we execute it; if the open fails we return without
  71. % error, presumabaly we don't have the font.  Before returning we restore the
  72. % dictionary stack.
  73.  
  74. /loadfont
  75. { 1 index =string copy                         % Prefix:
  76.   length                                       % length
  77.   3 index =string 2 index 100 getinterval cvs  % Prefix:name
  78.   length add                                   % length
  79.   1 index =string 2 index 100 getinterval copy % Prefix:name.suffix
  80.   length add                                   % length
  81.   =string exch 0 exch getinterval              % Truncate to length
  82.   mark countdictstack 2 sub
  83.       { currentdict end } repeat               % Pop dict stack
  84.   counttomark 1 add index                      % Get the file name
  85.   { (r) file } stopped                         % Try to open the file
  86.   { pop pop }                                  % Can't open it, ignore
  87.   { cvx exec }                                 % Opened OK, execute it
  88.   ifelse
  89.   counttomark { begin } repeat pop             % Restore dictionary stack
  90.   pop pop pop pop                              % Pop file name and arguments
  91. } bind def
  92.  
  93. % Find a font.  If it is not there we try in order:
  94. %
  95. %    Load       CGFonts:PS/name.psfont
  96. %    Load       PSFonts:name
  97. %    Substitute DefaultFont
  98. %
  99. % If none of these succeeds, the result will an invalidfont error.
  100.  
  101. /findfont
  102. {
  103. % Comment out the next 3 lines if you don't have the Gold Disk CG fonts
  104. %  dup FontDirectory exch known not             % Not in FontDirectory?
  105. %  { dup (CGFonts:PS/) (.psfont) loadfont       % Try to load from CGFonts:PS
  106. %  } if
  107. % Comment out the next 3 lines if you don't have a PSFonts: directory
  108.   dup FontDirectory exch known not             % Not in FontDirectory?
  109.   { dup (PSFonts:) () loadfont                 % Try to load from PSFonts:
  110.   } if
  111. % Substitute DefaultFont
  112.   dup FontDirectory exch known not             % Not in FontDirectory?
  113.   { FontDirectory /DefaultFont known           % DefaultFont defined?
  114.     { pop /DefaultFont } if                    % Substitute DefaultFont
  115.   } if
  116.   systemdict /findfont get exec                % If errors, will fail
  117. } bind def
  118.  
  119. % Define a dummy font
  120.  
  121. /DummyFont 10 dict dup begin
  122. /FontName /DummyFont def
  123. /FontMatrix [0.001 0 0 0.0001 0 0] def
  124. /FontType 3 def
  125. /FontBBox [0 0 0 0] def
  126. /Encoding StandardEncoding def
  127. /BuildChar { pop pop 0 0 0 0 0 0 setcachedevice } def
  128. /Painttype 0 def
  129. end definefont pop
  130.  
  131. % Establish the dummy font as the default, as some fonts need it to
  132. % define themselves.
  133.  
  134. FontDirectory /DefaultFont /DummyFont findfont put
  135.  
  136. % If you don't have Courier, comment this line out, or replace it with any
  137. % font you prefer.
  138.  
  139. FontDirectory /DefaultFont /Courier findfont put
  140.  
  141.